import java.util.Scanner;
public class ArraryAdd {
    public static void main(String[] args) {
        int []arr={1,2,3};
        Scanner x=new Scanner(System.in);
        System.out.println("请选择是否添加元素:yes/no");
        String n=x.next();
        if(n.equals("yes")){
            int []arr2=new int[arr.length+1];
            for (int i = 0; i <arr.length ; i++) {
                arr2[i]=arr[i];
            }
            System.out.println("请输入要添加的元素:");
            int sum=x.nextInt();
            arr2[arr2.length-1]=sum;
            arr=arr2;
        }
        for (int i = 0; i <arr.length ; i++) {
            System.out.print( arr[i]+" ");
        }

    }
}
